class Solution {
public:
    vector<int> diStringMatch(string s) {
        int left = 0, right = s.size();
        vector<int> ret;
        for(auto& e : s)
        {
            if(e == 'I') // 递增，先放最小
                ret.push_back(left++);
            else
                ret.push_back(right--);
        }
        ret.push_back(right); // 重合
        return ret;
    }
};